//
//  YJCateAnimation.m
//  Sports-Go
//
//  Created by rimi on 16/10/2.
//  Copyright © 2016年 YRL. All rights reserved.
//

#import "YJCateAnimation.h"
#define kWidth [UIScreen mainScreen].bounds.size.width
#define kHeigh [UIScreen mainScreen].bounds.size.height
#define rectLeftArm RzCGRectMake(1, 90, 40, 65)
#define rectRightArm RzCGRectMake(211 / 2 + 60, 90, 40, 65)
#define rectLeftHand RzCGRectMake(375/ 2 - 100, 200- 22, 40, 40)
#define rectRightHand RzCGRectMake(375/ 2 + 62, 200 - 22, 40, 40)
@interface YJCateAnimation ()
//猫的手
@property (strong,nonatomic) UIImageView *lefthand;
@property (strong,nonatomic) UIImageView *righthand;

//猫的蒙眼胳膊
@property (strong,nonatomic) UIImageView *lefthArm;
@property (strong,nonatomic) UIImageView *rightArm;
@end
@implementation YJCateAnimation

-(instancetype)initWithFrame:(CGRect)frame{
     if (self=[super initWithFrame:frame]) {
         [self drawView];
     }
     return self;
 }
-(void)drawView{
    
    UIImageView* header = [[UIImageView alloc] initWithFrame:RzCGRectMake(375/ 2 - 211 / 2, 100, 211, 109)];
    
    header.image=[UIImage imageNamed:@"header"];
    [self addSubview:header];
    
    _lefthArm=[[UIImageView alloc]initWithFrame:rectLeftArm];
    _lefthArm.image=[UIImage imageNamed:@"left"];
    
    [header addSubview:_lefthArm];
    
    
    _rightArm=[[UIImageView alloc]initWithFrame:rectRightArm];
    _rightArm.image=[UIImage imageNamed:@"right"];
    [header addSubview:_rightArm];
    
    
    UIView *loginview=[[UIView alloc]initWithFrame:RzCGRectMake(15, 200, 375-30, 160)];
    
    loginview.backgroundColor=[UIColor clearColor];
    [self addSubview:loginview];
    
    _lefthand = [[UIImageView alloc]initWithFrame:rectLeftHand];
    _lefthand.image = [UIImage imageNamed:@"hand"];
    [self addSubview:_lefthand];
    
    _righthand = [[UIImageView alloc]initWithFrame:rectRightHand];
    _righthand.image = [UIImage imageNamed:@"hand"];
    [self addSubview:_righthand];
    
}
- (void)openTheEyes{
    [UIView animateWithDuration:0.5 animations:^{
        
        self.lefthArm.frame = CGRectMake(self.lefthArm.frame.origin.x - 55*bi, self.lefthArm.frame.origin.y + 30*hbi, self.lefthArm.frame.size.width - 10, self.lefthArm.frame.size.height);
        
        self.rightArm.frame = CGRectMake(self.rightArm.frame.origin.x+53*bi, self.rightArm.frame.origin.y + 30*hbi, self.rightArm.frame.size.width - 10, self.rightArm.frame.size.height);
        
        self.lefthand.frame = CGRectMake(self.lefthand.frame.origin.x-70*bi, self.lefthand.frame.origin.y, 40*bi, 40*hbi);
        self.righthand.frame = CGRectMake(self.righthand.frame.origin.x +30*bi, self.righthand.frame.origin.y, 40*bi, 40*hbi);
    } completion:^(BOOL finished) {
        
    }];
    
}

- (void)closeTheEyes{
    
    
    [UIView animateWithDuration:0.5 animations:^{
        
        
        self.lefthArm.frame = CGRectMake(self.lefthArm.frame.origin.x + 55*bi, self.lefthArm.frame.origin.y - 30*hbi, self.lefthArm.frame.size.width + 10, self.lefthArm.frame.size.height);
        
        self.rightArm.frame = CGRectMake(self.rightArm.frame.origin.x - 53*bi, self.rightArm.frame.origin.y - 30*hbi, self.rightArm.frame.size.width + 10, self.rightArm.frame.size.height);
        
        self.lefthand.frame = CGRectMake(self.lefthand.frame.origin.x + 70*bi, self.lefthand.frame.origin.y, 0, 0);
        self.righthand.frame = CGRectMake(self.righthand.frame.origin.x - 30*bi, self.righthand.frame.origin.y, 0, 0);
    } completion:^(BOOL finished) {
        
    }];
    
}


@end
